Ternary Expressions
Ternary expressions behave identical as to how they would in C. They introduce no new keywords.
Old Codepluto
local maxif a > b thenmax = aelsemax = bend
New Codepluto
local max = a > b ? a : b
Try It Yourself
If Expressions
If expressions are an alternative syntax for ternary expressions:
pluto
local a = 6local b = 9local max = if a > b then a else b endprint(max) --> 9
Doesn't Lua already have ternaries?
While it is true that you can do something like this:
pluto
local max = a > b and a or b
Keep in mind that this falls apart when the true-expression has a falsy value:
pluto
local x = -1x = (x == -1 and nil or x)
In this case, x will be -1 despite the intention being to set it to nil. There are no such issues using Pluto's ternary expressions.